<?php

/**
* Register widgetized areas
*/

function widget_areas_init()
{
	register_sidebar( array(
		'name' => 'Before All Widget Area',
		'id' => 'before_all_widget_area',
		'description' => 'Before all widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Posts Widget Area',
		'id' => 'single_widget_area',
		'description' => 'Posts widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Page Widget Area',
		'id' => 'page_widget_area',
		'description' => 'Page widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Portofolio Widget Area',
		'id' => 'portofolios_widget_area',
		'description' => 'Portofolio widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Category Widget Area',
		'id' => 'category_widget_area',
		'description' => 'Category widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Archive Widget Area',
		'id' => 'archive_widget_area',
		'description' => 'Archive widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Search Widget Area',
		'id' => 'search_widget_area',
		'description' => 'Search widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Contact Widget Area',
		'id' => 'contact_widget_area',
		'description' => 'Contact widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	register_sidebar( array(
		'name' => 'Bottom Widget Area',
		'id' => 'bottom_widget_area',
		'description' => 'Bottom widget area',
		'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	) );
	
	// custom sidebars
	global $wpdb;
	$display_sidebars_query = 'SELECT * FROM `'.$wpdb->prefix.'lazar_sidebars` ORDER BY ID';
	$display_sidebars = $wpdb->get_results($display_sidebars_query);


	foreach ($display_sidebars as $display_sidebar)
	{
		register_sidebar( array(
			'name' => $display_sidebar->name,
			'id' => 'custom_sidebar_'.$display_sidebar->id,
			'description' => $display_sidebar->description,
			'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
			'after_widget' => '</li>',
			'before_title' => '<h3 class="widget_title">',
			'after_title' => '</h3>',
		) );
	}
	// END custom sidebars
	
	
	for ($i = 1; $i <= 6; $i++)
	{
		register_sidebar( array(
			'name' => 'Footer Widget Area '.$i,
			'id' => 'footer_widget_area_'.$i,
			'description' => 'Footer widget area nr. '.$i,
			'before_widget' => '<li id="%1$s" class="widget_container clearfix %2$s">',
			'after_widget' => '</li>',
			'before_title' => '<h3 class="widget_title">',
			'after_title' => '</h3>',
		) );
	}

}

/** Register sidebars INITIALIZATION !!! */
add_action( 'widgets_init', 'widget_areas_init' );

?>